imports('../../style/manage');

var template = require('template');

template.method('formatMobile', function(val){
    if(val){
        return val.replace(/^(\d{3})(\d{4})(\d{4})$/, '$1 $2 $3')
    }
    return ''
})

return {
    main:renders({
        <form class="ui-form e-pt10 e-pl20 e-ml10">
            <div class="ui-item e-mt20">
                <label class="ui-label ui-label-normal f-lh35 f-tal">企业名称</label>
                <input type="hidden" name="id" value="<%id??%>">
                <div class="f-fl f-pr">
                    <input type="text" autocomplete="off" name="name" value="<%name??%>" class="ui-input ui-input-normal" 
                        data-rule="{required:true}" data-message="{required:'企业名称不能为空'}">
                    <em class="ui-err"></em>
                </div>
            </div>
        </form>
        <div class="ui-form e-pb10 e-pl20 e-ml10">
            <div class="ui-item f-lh35 e-mt20">
                <label class="ui-label ui-label-normal f-tal">管理员</label>
                <span class="e-pl10"><%admin??%></span>
            </div>
            <div class="ui-item f-lh35 e-mt10">
                <label class="ui-label ui-label-normal f-tal">联系方式</label>
                <span class="e-pl10"><%mobile??%></span>
            </div>
            <div class="ui-item e-mt15">
                <label class="ui-label ui-label-normal f-tal f-lh25">企业员工</label>
                <div class="f-fl e-pl10 m-userlist">
                    <div class="userbox f-clearfix f-oa">
                        <%each empList user%>
                        <%include 'user'%>
                        <%/each%>
                    </div>
                    <span class="j-add f-cblue f-cp <%if empList && empList.length%>e-mt20<%else%>e-mt5<%/if%>">
                        <i class="iconfont">&#xe63a;</i>
                        <b class="e-mt-1 e-ml5">增加员工</b>
                    </span>
                </div>
            </div>
        </div>
    }),
    user:renders({
        <div class="f-lh25 f-clearfix e-mb20 e-pr20 item">
            <span class="user f-toe e-mr10" title="<%user.name%>"><%user.name%></span>
            <span><%formatMobile | user.mobile%></span>
            <span class="ui-checkradio ui-checkradio-switches f-fr">
                <input type="checkbox" name="userid" value="<%user.id%>"<%if user.status == '0'%> checked<%/if%>>
            </span>
        </div>
    })
}